/**
 * @Author 韦建韩
 * @Date 2022/3/24
 */
package com.zczn.order_system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zczn.order_system.entity.ObjectArg;
import com.zczn.order_system.entity.UserInfo;
import com.zczn.order_system.entity.dto.ResultDto;
import com.zczn.order_system.entity.pojo.Result;
import com.zczn.order_system.service.IService.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("admin")
@CrossOrigin
public class UserController {
    @Autowired
    IUserService userService;
    @RequestMapping("userInfoList")
    public Result userInfoList(@RequestBody Page page){

        ResultDto userList = userService.getUserList(page);
        Result result = Result.doCreate();
        result.setCode(userList.getCode());
        result.setData(userList.getData());
        return result;
    }
    @RequestMapping("addUser")
    public Result addUser(@RequestBody UserInfo userInfo){
        userService.addUserInfo(userInfo);
        return Result.doCreate();
    }
    @RequestMapping("recharge")
    public Result userRecharge(@RequestBody ObjectArg arg){
        userService.recharge(arg);
        return Result.doCreate();
    }
}
